home *** CD-ROM | disk | FTP | other *** search
- data segment word public
- extrn pitch:WORD ; number of bytes per scan line
- data ends
-
-
-
- code segment byte public
- assume cs:code,ds:data
- public gsol
- page 60,132
- ; val val val val VAR VAR
- ; procedure gsol(gdx,gdy,color,fontlines,fontbase,instring);
-
- gdx equ [BP+20]
- gdy equ [BP+18]
- backgnd equ [BP+16]
- color equ [BP+14]
- fontlines equ [BP+12]
- fontbase equ [BP+8]
- instring equ [BP+4]
-
- gsol proc NEAR
-
- push bp
- mov bp,sp
- push ds
- ;
- mov ax,pitch
- mov CS:[lpitch],ax ; save pitch in CS: since DS is going to change
-
-
- ; Calculate byte address (segment & offset) and bit mask
-
- ;
- mov dx,040h ; bios data segment
- mov ds,dx
- mov si,062h
- mov al,[si] ; get active display page
-
- mov dx,0A000h ; base page of EGA/VGA memory
- ;
- or al,al ; set flags
- jz page0 ; if zero, skip ofset add
- add dh,8 ; ofset to second page base of A800h
-
- page0:
- mov ds,dx ; DS := EGA/VGA buffer segment address
-
- mov dx,3CEh ; Graphics Controller port address
- mov ax,5
- out dx,al ; select register 5 (mode)
-
- inc dx ; dx = 3CFh
- in al,dx ; read current mode
- and al,0FCh
- or al,02h ; set to mode 2
- out dx,al
-
- dec dx ; dx = 3CEh
- mov al,8
- out dx,al ; leave pointing to bit mask register
-
- mov dx,3C4h ; Sequencer/Map Mode port address
- mov ax,0F02h
- out dx,ax ; Select "Map Mask" register 2, enable all planes
-
-
- ;
- mov ax,gdx ; get X address from stack frame
- shr ax,1
- shr ax,1
- shr ax,1 ; compute memory address ofset AX := x/8
- mov bx,ax ; save back on stack
- ;
- les SI,instring ; get doulbleword base address of string
- xor ch,ch ; clear ch
- mov cl,byte ptr ES:[si] ; points to length of string
- or cl,cl ; set flags
- jz nullstring ; if length is zero, skip everything
-
- mov ax,gdy ; get Y address (a pixel row)
- add ax,fontlines ; add in lines in font as ofset to Y value
- dec ax ; subtract 1 because cx is 1 based inst. of 0
- mov dx,CS:[lpitch]
- mul dx ; AX := (y * 80) ([pitch] bytes per row)
-
- add ax,bx ; AX := (y * 80) + x/8 (offset)
-
- mov di,ax ; save EGA/VGA memory ofset in DI
-
- ; Get the "Bit Mask" register address
- mov dx,3CFh ; bit mask register
-
-
-
- strloop: ; loop for number of characters in string
- push CX ; save string count for outer loop
- inc SI ; make si point to nextchar
- mov bl,byte ptr ES:[SI] ; SI points to next char - read into bx
- inc bl ; increment char code : draw char from bot to top
- mov ax,fontlines ; get number of lines/char in font
- mov cx,ax ; keep for use as char-loop counter
- mul bl ; ax := bl (character) * al (bytes/char)
- mov bx,ax ; leave font character ofset in BX
- push ES ; save char string seg.
- push SI ; save char string pointer
- push DI ; save EGA/VGA destination
- ;
- ; loop for the number of lines
- ;
-
- les SI,fontbase ; get dblword base address of font
- ;
- ;
-
- mov ah,0ffh ; bit mask constant
- dec cx ; one less pass thru loop, due to early latch read
-
- dec bx ; move UP to next scanline in font
-
- mov al,ah
- out dx,al ; enable all bits in bit mask into reg 8
- ;
- mov al,backgnd
- mov [di],al ; Set all bits to "backgnd color".
-
- mov al,[di] ; Latch the bit plane data with dummy read
- ; latch only once for all writes this character
-
- charloop: ; loop through the font's scanlines bottom to top
-
-
- ; Set bits in the appropriate bit planes by writing color value to EGA/VGA memory
-
- mov al,ES:[BX][SI] ; get bit mask byte from font: bx=font char ofs
- out dx,al ; load bit mask into reg 8
-
- mov al,color
- mov [di],al ; write foreground color with bit mask.
-
- ; 8
- sub di,CS:[lpitch] ; move up one line in EGA/VGA memory
-
- dec bx ; move UP to next scanline in font
-
- mov al,ah
- out dx,al ; enable all bits in bit mask, reg 8
- ;
- mov al,backgnd
- mov [di],al ; Set all bits to "backgnd color".
-
-
- loop charloop ; decrement cx and do next scanline
-
- ; perform final foreground write
-
- mov al,ES:[BX][SI] ; get bit mask byte from font: bx=font char ofs
- out dx,al ; load bit mask into reg 8
-
- mov al,color
- mov [di],al ; write foreground color with bit mask.
-
-
- pop DI ; get back EGA/VGA destination
- inc DI ; move screen position to next char over
-
- pop SI ; pop character pointer
- pop ES ; " " segement
-
- pop CX ; get outer loop - counting chars in string
- loop strloop
-
- nullstring:
- ; Restore default EGA/VGA graphics status
-
-
-
-
- mov dx,3CEh ; Graphics Controller port address
- mov ax,5
- out dx,al ; select register 5 (mode)
-
- inc dx ; dx = 3CFh
- in al,dx ; read current mode
- and al,0FCh ; set to write mode 0
- out dx,al
-
- dec dx ; dx = 3CEh
- mov ax,0FF08h ; reset bitmask register to all on
- out dx,ax ; ... Graphics Controller register 8
-
- pop ds
- pop bp
- ret 16d
- gsol endp
-
- lpitch dw 0 ; local CS storage for pitch
-
-
- code ends
-
- end
-